package objects.base;

import java.util.ArrayList;

public class Bracketing {
	public static ArrayList<Bracket> zscoreBracket;
	public static double 
	z1 = 20, // zero frequency trick here
	z2 = 25,
	z3 = 15,
	z4 = 12,
	z5 = 10,
	z6 = 10,
	z7 = 8,
	z8 = 9,
	z9 = 6,
	z10 = 5,
	z11 = 5;

	public static void init(){
		zscoreBracket = new ArrayList<Bracket>();
		Bracket b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11;
		b1 = new Bracket(0, 5, z1);
		b2 = new Bracket(5, 10, z2);
		b3 = new Bracket(10, 20, z3);
		b4 = new Bracket(20, 30, z4);
		b5 = new Bracket(30, 40, z5);
		b6 = new Bracket(40, 50, z6);
		b7 = new Bracket(50, 60, z7);
		b8 = new Bracket(60, 70, z8);
		b9 = new Bracket(70, 80, z9);
		b10 = new Bracket(80, 90, z10);
		b11 = new Bracket(90, 101, z11);
		zscoreBracket.add(b1);
		zscoreBracket.add(b2);
		zscoreBracket.add(b3);
		zscoreBracket.add(b4);
		zscoreBracket.add(b5);
		zscoreBracket.add(b6);
		zscoreBracket.add(b7);
		zscoreBracket.add(b8);
		zscoreBracket.add(b9);
		zscoreBracket.add(b10);
		zscoreBracket.add(b11);
	}

	public static double getZscoreThreshold(double proportion){
		double zscore = 0;
		if(zscoreBracket == null)
			init();
		for(Bracket b : zscoreBracket){
			if(b.isInsideBracket(proportion)){
				zscore = b.getZscore();
				break;
			}
		}
		return zscore;
	}

	public static boolean IsUpperZScore(double proportion,double zscore){
		return zscore >= getZscoreThreshold(proportion);
	}
}
